<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改【请填写功能名称】')"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-fastener-edit" th:object="${carPartFastener}">
        <input name="id" th:field="*{id}" type="hidden"/>
        <input name="cardId" th:field="*{cardId}" type="hidden"/>
        <input name="cardInfoId" th:field="*{cardInfoId}" type="hidden"/>
        <input name="fastenerType" th:field="*{fastenerType}" type="hidden"/>

        <div class="form-group">
            <label class="col-sm-1 control-label">图片</label>
            <div class="col-sm-9"
                 th:include="system/common/file_select :: multiple_img(_file_id='multipleFile',_img_list_id='left_img_list',_file_list=${@file.getFiles(carPartFastener.id,'car_info_parts_fastener')})"/>
            <div class="col-sm-2">
                <div class="btn btn-primary" onclick="submitHandler()">保存</div>
                <div class="btn btn-primary" onclick="del()">删除</div>
            </div>
        </div>
        <div class="form-group" th:if='${carPartFastener.fastenerType eq "0"}'>
            <label class="col-sm-2 control-label">紧固件数量：</label>
            <div class="col-sm-2"><input name="nums" th:field="*{nums}" class="form-control" type="text"/></div>
            <label class="col-sm-2 control-label">紧固件类型：</label>
<!--            <div class="col-sm-2">-->
<!--                <select class="form-control" id="infoMap_fastener_type" name="fastenerType"-->
<!--                        th:with="type=${@carFastenerType.list()}" onchange="aaa(this)">-->
<!--                    <option th:each="dict : ${type}" th:text="${dict.name}" th:value="${dict.id}"-->
<!--                            th:field="*{carPartFastener.fastenerType}" th:href="${dict.img}"></option>-->
<!--                </select>-->
<!--            </div>-->
            <label class="col-sm-2 control-label">紧固件型号：</label>
            <div class="col-sm-2"><input name="model" th:field="*{model}" class="form-control" type="text"/></div>
            <label class="col-sm-2 control-label">表面处理工艺：</label>
            <div class="col-sm-2"><input name="craft" th:field="*{craft}" class="form-control" type="text"/></div>
            <label class="col-sm-2 control-label">紧固件强度：</label>
            <div class="col-sm-2"><input name="vol" th:field="*{vol}" class="form-control" type="text"/></div>
        </div>
        <div class="form-group" th:if='${carPartFastener.fastenerType eq "1"}'>
            <label class="col-sm-2 control-label">定位数量：</label>
            <div class="col-sm-2"><input name="nums" th:field="*{nums}" class="form-control" type="text"/></div>
            <label class="col-sm-2 control-label">定位类型：</label>
            <div class="col-sm-2"><input name="model" th:field="*{model}" class="form-control" type="text"/></div>
            <label class="col-sm-2 control-label">表面处理工艺：</label>
            <div class="col-sm-2"><input name="craft" th:field="*{craft}" class="form-control" type="text"/></div>
        </div>
        <div class="form-group" th:if='${carPartFastener.fastenerType eq "2"}'>
            <label class="col-sm-2 control-label">细节数量：</label>
            <div class="col-sm-2"><input name="nums" th:field="*{nums}" class="form-control" type="text"/></div>
            <label class="col-sm-2 control-label">细节类型：</label>
            <div class="col-sm-2"><input name="model" th:field="*{model}" class="form-control" type="text"/></div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">材料：</label>
            <div class="col-sm-2"><input name="material" th:field="*{material}" class="form-control" type="text"/></div>
            <label class="col-sm-2 control-label">单个重量：</label>
            <div class="col-sm-2"><input name="weight" th:field="*{weight}" class="form-control" type="text"/></div>
            <label class="col-sm-2 control-label">总重：</label>
            <div class="col-sm-2"><input name="weightTotal" th:field="*{weightTotal}" class="form-control" type="text"/></div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">备注：</label>
            <div class="col-sm-10">
                <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script th:inline="javascript">
    var prefix = ctx + "system/fastener";
    $("#form-fastener-edit").validate({
        focusCleanup: true
    });
    function del() {
        let id = [[${carPartFastener.id}]];
        $.operate.get(prefix + "/remove/" + id, function (data) {
            $('#iframe-fasteners-'+id, top.document).remove();
        });
    }

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-fastener-edit').serialize());
        }
    }

    $(function () {
        multipleFile_manager.init({busId: [[${carPartFastener.id}]], busType: 'car_info_parts_fastener', fileType: 'img'});
    });
</script>
</body>
</html>
